package domain

import (
	"context"
	"google.golang.org/protobuf/proto"
)

func (x *Merchant) MarshalBinary() (data []byte, err error) {
	return proto.Marshal(x)
}

func (x *Merchant) UnmarshalBinary(data []byte) error {
	return proto.Unmarshal(data, x)
}

//type Merchant struct {
//	Id                int32
//	Name              string
//	PriceArea         int32
//	SalesmanId        int32
//	Discount          int8
//	ContractDiscount  int8
//	SettleType        int8
//	Introduction      string
//	ProvinceCode      string
//	CityCode          string
//	AreaCode          string
//	Address           string
//	Lng               string
//	Lat               string
//	Status            int8
//	InstitutionalType int8
//	MainBusiness      string
//	CreatedAt         time.Time
//	UpdatedAt         time.Time
//	Certification     MerchantCertification
//}
//
//type MerchantCertification struct {
//	Id                           int32
//	LegalPerson                  string
//	LegalPersonCardId            string
//	LegalPersonIdentityFrontSide string
//	LegalPersonIdentityBackSide  string
//	BusinessLicense              string
//	BusinessLicensePhoto         string
//	BusinessLicenseStartFate     *time.Time
//	BusinessLicenseEndFate       *time.Time
//	MedicalLicense               string
//	MedicalLicenseName           string
//	MedicalLicensePhoto          string
//	MedicalLicenseStartDate      *time.Time
//	MedicalLicenseEndDate        *time.Time
//	IsNonprofit                  int8
//	Property                     int8
//	DrugLicense                  string
//	DrugLicensePhoto             string
//	ContractPhoto                string
//	ContractStartDate            *time.Time
//	ContractEndDate              *time.Time
//	CreatedAt                    time.Time
//	UpdatedAt                    time.Time
//}

type SearchMerchantList struct {
	Id        int32
	Name      string
	PriceArea int32
	Status    int8
	PageSize  int32
	PageNo    int32
}

type MerchantUsecase interface {
	ListMerchants(ctx context.Context, search *SearchMerchantList) ([]*Merchant, int32, error)
	GetMerchant(ctx context.Context, id int32, fields []string) (*Merchant, error)
	CreateMerchant(ctx context.Context, do *Merchant) (*Merchant, error)
	UpdateMerchant(ctx context.Context, do *Merchant, fields []string) (*Merchant, error)
}

type MerchantRepo interface {
	ListItems(ctx context.Context, search *SearchMerchantList) ([]*Merchant, int32, error)
	GetItem(ctx context.Context, id int32, fields []string) (*Merchant, error)
	CreateItem(ctx context.Context, do *Merchant) (*Merchant, error)
	UpdateItem(ctx context.Context, do *Merchant, fields []string) (*Merchant, error)
}

type MerchantCacheRepo interface {
	GetMerchant(ctx context.Context, id int32) (*Merchant, error)
	SetMerchant(ctx context.Context, do *Merchant) error
}
